<?

$link = $_GET[q];
$option = 1; //To display just online & offline set this to 0.

 if(substr($link,0,4)!="http"){ 
  $link = "http://".$link;
 }

 $timestart = microtime();

 $churl = @fopen($link,'r');

 $timeend = microtime();
 $diff = number_format(((substr($timeend,0,9)) + (substr($timeend,-10)) - (substr($timestart,0,9)) - (substr($timestart,-10))),4);
 $diff = $diff*100;
 
 if (!$churl) {
  $message="<b>$link is <div class=offline>Offline</div></b>";
 }else{
  $message="<b>$link is <div class=online>Online</div></b> "; if($option==1){ $message = $message."[ Ping Time: ".$diff."ms ]";}
 }
 echo $message;
?>